namespace OracleInternal.BinXml
{
	internal class ObxmlToken
	{
		private object tokenLock = new object();

		internal ulong TokenId;

		internal ulong NamespaceId;

		private const int DefaultCharArraySize = 32;

		private static char[] m_TokenCharArray = new char[32];

		internal string Uri;

		internal TokenTypes TokenType;

		internal byte[] m_TokenNameBytes;

		internal string m_TokenName
		{
			get;
			set;
		}

		internal string TokenName
		{
			get
			{
				if (!string.IsNullOrEmpty(m_TokenName))
				{
					return m_TokenName;
				}
				if (m_TokenNameBytes != null)
				{
					lock (tokenLock)
					{
						int charCount = m_TokenCharArray.Length;
						if (string.IsNullOrEmpty(m_TokenName))
						{
							if (m_TokenNameBytes.Length > charCount)
							{
								m_TokenCharArray = new char[m_TokenNameBytes.Length];
								charCount = m_TokenCharArray.Length;
							}
							ObxmlStream.Utf8_AL32UTF8_CHARSET.ConvertBytesToChars(m_TokenNameBytes, 0, m_TokenNameBytes.Length, m_TokenCharArray, 0, ref charCount);
							m_TokenName = new string(m_TokenCharArray, 0, charCount);
							m_TokenNameBytes = null;
						}
					}
				}
				return m_TokenName;
			}
			set
			{
				m_TokenName = value;
			}
		}

		internal bool IsAttribute => TokenType == TokenTypes.AttributeToken;

		internal bool IsNamespaceToken => TokenType == TokenTypes.NamespaceToken;

		internal bool IsPrefixToken => TokenType == TokenTypes.PrefixToken;

		internal bool IsElementToken => TokenType == TokenTypes.ElementToken;

		internal ObxmlToken(ulong tokenId, string tokenName, TokenTypes tokenType = TokenTypes.ElementToken)
		{
			TokenId = tokenId;
			TokenName = tokenName;
			TokenType = tokenType;
		}

		internal ObxmlToken(ulong tokenId, ulong namespaceId, string tokenName, TokenTypes tokenType = TokenTypes.ElementToken)
		{
			TokenId = tokenId;
			NamespaceId = namespaceId;
			TokenName = tokenName;
			TokenType = tokenType;
		}

		internal ObxmlToken(ulong tokenId, byte[] tokenNameBytes, TokenTypes tokenType = TokenTypes.ElementToken)
		{
			TokenId = tokenId;
			m_TokenNameBytes = tokenNameBytes;
			TokenType = tokenType;
		}

		internal ObxmlToken(ulong tokenId, ulong namespaceId, byte[] tokenNameBytes, TokenTypes tokenType = TokenTypes.ElementToken)
		{
			TokenId = tokenId;
			NamespaceId = namespaceId;
			m_TokenNameBytes = tokenNameBytes;
			TokenType = tokenType;
		}
	}
}
